home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
8174
/
8174.xpi
/
chrome
/
antbar.jar
/
content
/
grabber
/
parsers
/
parsergeneric.js
< prev
next >
Wrap
Text File
|
2009-12-30
|
1KB
|
71 lines
//
// downloadergeneric.js
// firefox
//
// Created by Zak on 2008-06-17.
// Copyright 2008-2009 Ant.com. All rights reserved.
//
/**
* Inherit from ParserInterface
*/
var AntParserGeneric = function () {}
AntParserGeneric.prototype = new AntParser;
AntParser.prototype.constructor = AntParser;
/**
* Parse page content and find flvs
*/
AntParserGeneric.prototype.isFlvAvailable = function ()
{
var re = /(http:\/\/[^;><'"]+\.flv)(?=[?&"'\s])/gi;
var html;
try
{
html = this.getCurrentDocument().getElementsByTagName("html")[0].innerHTML;
}
catch (e)
{
return false;
}
this.flvArr = new AntArray();
this.flvArr.fromArray(html.match(re));
if (!this.flvArr)
return false;
this.flvArr = this.flvArr.uniq();
return this.flvArr.length > 0;
}
/**
* Interface implementation
*/
AntParserGeneric.prototype.getFlvArray= function ()
{
if (this.isFlvAvailable())
{
var loc = AntLib.safeGet(this.getCurrentDocument(), "location");
if (!loc)
return false;
var host = AntLib.getSiteName(loc);
var title = AntLib.safeGet(this.getCurrentDocument(), "title");
var arr = new AntArray();
for (var i = 0; i < this.flvArr.length; i++)
{
var link = new AntFlvLink({origin:host, url:this.flvArr[i], name:title, doc:this.getCurrentDocument()});
arr.push(link);
}
return arr;
}
return null;
}